<template>
    <div class="teacher">
        <h3>教师姓名：{{name}}</h3>
        <h3>教师姓名：{{sex}}</h3>
        <h3>教师姓名：{{name}}</h3>

        <!-- 学生组件传过来的数据 -->
         <h4>学生信息：{{stuName}}</h4>
    </div>
</template>
<script>
    export default{
        name:'Teacher',
        data() {
            return {
                name:'曹老师',
                sex:'女',
                stuName:''
            }
        },
        methods: {
            submit(){
                this.getName(this.name)
            }
        },

        //挂载
        mounted() {
            // 绑定
            this.$bus.on('getStuName',(val)=>{
                this.stuName=val
            })
        },
        unmounted() {
            // 解绑
            this.$bus.off('getStuName')
        },


    }

</script>

<style scoped>
    
</style>